function GetRequest() {
    var url = location.search; //获取url中"?"符后的字串
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
        var str = url.substr(1);
        strs = str.split("&");
        for(var i = 0; i < strs.length; i ++) {
            theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
        }
    }
    return theRequest;
}
function toDecimal(x) {
    var f = parseFloat(x);
    if (isNaN(f)) {
        return false;
    }
    var f = x/100;
    var s = f.toString();
    var rs = s.indexOf('.');
    if (rs < 0) {
        rs = s.length;
        s += '.';
    }
    while (s.length <= rs + 2) {
        s += '0';
    }
    return s;
}
function payOrderNum() {
    var ordernum= request["ordernum"];
    // alert(ordernum);
    var paramData = {"ordernum":ordernum,"token": cochoApp.getTokenByStorage()};
    $.ajax({
        type: "post",
        async: true,//异步，如果等于false 那么就是同步
        url: cochoApp.baseUrl + "/members/phone/orderNum.do",
        dataType: "json",
        data: paramData,
        success: function (data) {
            if (data != null) {
                if (data.statusCode == "SUCCESS") {
                    var obj=data.dataRows[0];
                    if(obj!=null){
                        if(obj.respcd=="00"){
                            payOrderNumSuccess(data);
                        }else{
                            setTimeout("payOrderNum()",3000)
                        }
                    }

                } else {
                    return false;
                }
            } else {
                alert("登录失败,请联系管理员解决！");
                return false;
            }
        },
        error: function (data) {
            alert("请求服务器出错！");
            return false;
        }
    });
}
function payOrderNumSuccess(data) {
  //  console.log(data)
    var obj=data.dataRows[0];
    if(obj!=null){
        //alert( obj.respcd);
        if(obj.respcd=="00"){
            var rdurl=cochoApp.baseUrl +"/control/phone/payResult.jsp?money="+toDecimal(request["money"]);
            console.log(rdurl);
            window.location.href =rdurl;
        }
    }else{
        alert("订单不存在！！！");
    }
}
function toPayType(ty){
    var x=''
    switch (ty)
    {
        case 'WXP':
            x="微信";
            break;
        case 'ALP':
            x="支付宝";
            break;
    }
    return x;
}

function payinit(){
    $('#paytype').html("请用"+toPayType( request["paytype"])+"扫描");
    $('#imgsrc').attr("src", request["url"]);
    $('#money').html("付款金额："+toDecimal(request["money"]));
    $('#mContent').show();
}
var request = new Object();
request = GetRequest();
payinit();